<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="pc/include :: header('编辑文档')" />
</head>
<body>
<th:block th:include="pc/include :: top" />
<div class="iw">
    <div class="crumbs">
        <p>当前位置：<a href="/">首页</a> > <a th:href="@{/detail.htm(docid=${doc.docid})}" th:text="${doc.title}" ></a> > 编辑文档</p>
    </div>
    <div class="upload_steptwo" style="display:block">
        <div class="steptwo_h1">
            <h3 class="fl">请修改文档信息，完成编辑</h3>
        </div>
        <div class="steptwo_div">
            <br>
            <div class="steptwo_body">
                <form>
                    <div class="up-l">
                        <div class="doc_title">
                            <label>
                                <i>*</i>标题：</label>
                            <input name="title" type="text" th:class="${doc.exten}" th:value="${doc.title}" />
                            <input name="docid" type="hidden" th:value="${doc.docid}">
                            <span>&nbsp;</span>
                        </div>
                        <div class="doc_keywd">
                            <label>关键字：</label>
                            <input name="keyword" type="text" th:value="${doc.keyword}" />
                            <span>&nbsp;</span>
                        </div>
                        <div class="doc_short">
                            <label>简介：</label>
                            <textarea name="word" th:text="${doc.word}"></textarea>
                            <span>&nbsp;</span>
                        </div>
                        <div class="doc_readpay">
                            <label><i>*</i>阅读售价：</label>
                            <input name="readpay" type="number" th:value="${doc.readpay}" />
                            <span th:text="${systradesets.glodunit}"></span>
                        </div>
                        <div class="doc_preview">
                            <label>可免费预览：</label>
                            <input name="preview" type="number" th:value="${doc.preview}" />
                            <span>页</span>
                        </div>
                        <div class="doc_downpay">
                            <label><i>*</i>下载售价：</label>
                            <input name="downpay" type="number" th:value="${doc.downpay}" />
                            <span th:text="${systradesets.glodunit}"></span>
                        </div>
                    </div>
                    <div class="up-r">
                        <div class="doc_type">
                            <label>
                                <i>*</i>分类：</label>
                            <div style="display:inline"></div>
                            <span>&nbsp;</span>
                        </div>
                        <div class="doc_filter" th:utext="${filter}">

                        </div>
                        <a class="btn_upload">
                            <i class="fa fa-save"></i>保存信息</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="upload_stepthr">
        <div class="p1">
            <i class="fa fa-check-circle-o"></i>文档已修改</div>
        <div class="p2">您可以
            <a th:href="@{/detail.htm(docid=${doc.docid})}">查看修改的文档</a>
        </div>
        <div class="p3">或
            <a th:href="@{/user/center}">进入用户中心</a>
        </div>
    </div>
    <div class="upload_info">
        <h3>温馨提示</h3>
        <p>1.您所在的用户组，上传大小<span th:if="${ugroup.uploadsize==-1}" style="color:#f00">不限制</span>
        <div th:remove="tag" th:unless="${ugroup.uploadsize==-1}"> 限制为 <span style="color:#f00"><span th:remove="tag" th:text="${ugroup.uploadsize}"></span>M</span></div>。</p>
        <p>2.支持批量上传，支持拖拽上传，批量设置分类等</p>
        <p>3.支持多种文档类型：</p>
        <ul>
            <li><i class="doc"></i>doc,docx</li>
            <li><i class="ppt"></i>ppt,pptx</li>
            <li><i class="xls"></i>xls,xlsx</li>
            <li><i class="wps"></i>wps</li>
            <li><i class="et"></i>et</li>
            <li><i class="dps"></i>dps</li>
            <li><i class="vsd"></i>vsd</li>
            <li><i class="pot"></i>pot</li>
            <li><i class="pps"></i>pps</li>
            <li><i class="epub"></i>epub</li>
            <li><i class="pdf"></i>pdf</li>
            <li><i class="rtf"></i>rtf</li>
            <li><i class="txt"></i>txt</li>
        </ul>
        <p>4.支持多种图片格式，如果多张图片请放到压缩包中上传：</p>
        <ul>
            <li><i class="doc"></i>jpg,jpeg</li>
            <li><i class="ppt"></i>png</li>
            <li><i class="xls"></i>gif</li>
            <li><i class="wps"></i>bmp</li>
        </ul>
        <p>5.支持压缩包，压缩包可以包含多张图片或一份文档，如果含有多分文档或文档和图片都有，我们只会提取一份文档</p>
        <p>6.上传涉及侵权内容的文档或图片我们有权利在不通知用户的情况下进行删除</p>
        <p>7.上传有问题需要帮助?可以 <a href="tencent://message/?uin=<?php echo $site->qq ?>&Site=<?php echo $site->host ?>&Menu=yes">联系客服</a></p>
    </div>
</div>
<th:block th:include="pc/include :: footer" />
<script th:src="@{/js/ui-select.js}"></script>
<script>
    $(function() {
        $(".doc_type div").ui_select(eval('([(${json})])'), 'typeid', '[(${type1})]');

        $(".doc_type .ui-select div").html('[(${type2})]<i></i>');
        //$(".doc_type .ui-select input").val('<?php echo $doc->typeid ?>');

        if ('[(${doc.readpay})]' == '0') {
            $(".doc_preview").hide();
        }

        $(".upload_steptwo").on("change",".doc_readpay input", function() {
            if ($(this).val() == '0') {
                $(this).parent().next().hide();               
            } else {
                $(this).parent().next().show();
            }
        });

        $(".upload_steptwo").on("click", ".btn_upload", function() {
            var $form = $(this).parent().parent();
            var $form_title = $form.find("input[name='title']");
            var $form_type = $form.find(".doc_type input");
            var $form_filter = $form.find("input[name='filter[]']");

            if ($form_title.val() == '') {
                $form_title.addClass('error');
                Message('请输入文档标题');
                return;
            } else {
                $form_title.removeClass('error');
            }
            if ($form_type.val() == '') {
                $form_type.addClass('error');
                Message('请选择文档分类');
                return;
            } else {
                $form_type.removeClass('error');
            }

            if ('[(${sysdocset.mintype})]' == '1' && $form_type.val().split('-').length < $form.find(".doc_type .ui-select span").children().length) {
                $form_type.addClass('error');
                Message('文档分类需要选到最后一级');
                return false;
            } else {
                $form_type.removeClass('error');
            }

            var fno = false;
            $form_filter.each(function () {
                if ('[(${sysdocset.minfilter})]' == '1' && $(this).val() <= 0) {
                    fno = true;
                    return;
                }
            });

            if (fno) {
                $form_type.addClass('error');
                Message('请设置附加分类');
                return false
            } else {
                $form_type.removeClass('error');
            }

            $.post("/user/center/editsave", $form.serialize(), function(data) {
                if (data) {
                    $(".upload_steptwo").hide();
                    $(".upload_stepthr").show();
                } else {
                    Message("保存失败");
                }
            });
        });
    });
</script>